<template>
  <div class="container">
    <el-tabs type="border-card">
      <el-tab-pane label="检修建议">
        <baseTable
          class="table"
          :tableSetting="tabConfig1"
          ref="table1"
        ></baseTable>
      </el-tab-pane>
      <el-tab-pane label="检修记录">
        <baseTable
          class="table"
          :tableSetting="tabConfig2"
          ref="table1"
        ></baseTable>
      </el-tab-pane>
      <!-- <el-tab-pane label="BIM模型">
        <model :equipmentInfo="{id: '06a3ed706c80446a9d57d805a936fc07'}"></model>
      </el-tab-pane> -->
    </el-tabs>
  </div>
</template>

<script>
// import model from '@/views/equipmentLedger/parameterInfor/model'
export default {
  components: {
    // model,
  },
  props: {
    // 自定义类型，用来在init函数对tabConfig1进行修改控制
    customType: {
      type: String,
      default: "",
    },
    // 表格数据
    tableData: {
      type: Object,
      default: function () {
        return {};
      },
    },
    // 表格配置信息
    tableInfo: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      tabConfig1: {
        indexShow: true, // 序号显示
        height: 400,
        column: [
          {
            label: "设备类型名称",
            prop: "typeName",
            required: true,
            showTooltip: false,
          },
          {
            label: "缺陷关键字",
            prop: "keys",
            required: true,
            showTooltip: false,
          },
          {
            label: "故障原因",
            prop: "errorCase",
            required: true,
            showTooltip: false,
          },
          {
            label: "故障描述",
            prop: "errorDesc",
            required: true,
            showTooltip: false,
          },
          {
            label: "处理方式",
            prop: "solution",
            required: true,
            showTooltip: false,
          },
        ],
        data: this.tableData.maintenanceSuggestions,
        rowClick: (row) => {
          console.log(row);
          //   let obj = { id: row.changeId, type: "directorChange" };
          //   this.gotoDetails(obj);
        },
      },
      tabConfig2: {
        indexShow: true, // 序号显示
        height: 400,
        column: [
          {
            label: "工单名称",
            prop: "title",
            required: true,
            showTooltip: false,
          },
          {
            label: "工单类型",
            prop: "orderType",
            required: true,
            formatter: (data) => {
              let obj = this.$store.getters['dirtData']('order_type').find(i => {
                return i.value === data.orderType
              })
              return obj ? obj.label : '-'
            }
          },
          {
            label: "设备名称",
            prop: "equipmentName",
            required: true,
            showTooltip: false,
          },
          {
            label: "作业单位",
            prop: "deptManageName",
            required: true,
            showTooltip: false,
          },
          {
            label: "创建人",
            prop: "createByName",
            required: true,
            showTooltip: false,
          },
          {
            label: "创建时间",
            prop: "createTime",
            required: true,
            showTooltip: false,
          },
        ],
        data: this.tableData.maintenanceRecords,
        rowClick: (row) => {
          // 缺陷单
          if (row.orderType === 'defect') {
            this.gotoDetails("defectOrderDetails", {
              id: row.id || '',
              status: row.status || '',
            })
            return
          }
          // 巡视单
          if (row.orderType === 'patrol') {
            this.gotoDetails("patrolOrderDetails", {
              id: row ? row.id : "",
              pageType: row.type ? row.type : "edit",
            })
            return
          }
          // 日常维护单
          if (row.orderType === 'maintain') {
            this.gotoDetails("normalMaintenanceDetails", {
              id: row.id || "",
              pageType: row.type || "edit",
              status: row.status || "",
            })
            return
          }
          // 计划检修
          if (row.orderType === 'repair') {
            this.gotoDetails("planRepairDetails", {
              id: row.id || "",
              pageType: row.type || "edit",
              status: row.status || "",
            })
            return
          }
          // 大修工单
          if (row.orderType === 'overhaul') {
            this.gotoDetails("overhaulDetails", {
              id: row.id || "",
              pageType: row.type || "edit",
            })
            return
          }
          // 试验工单
          if (row.orderType === 'experiment') {
            this.gotoDetails("experimentOrderDetails", {
              id: row.id || "",
              pageType: row.type || "edit",
              status: row.status || "",
            })
            return
          }
          console.log(row);
          //   let obj = { id: row.changeId, type: "directorChange" };
          //   this.gotoDetails(obj);
        },
      },
    };
  },
  methods: {
    gotoDetails(name, params) {
      let { href } = this.$router.resolve({
        name,
        query: params,
      });
      window.open(href, "_blank");
    }
  },
};
</script>

<style lang="less" scoped>
.container {
  .button {
    text-align: left;
  }
  /deep/ .el-tabs--border-card {
    border-radius: 4px 4px 0 0;
  }
  /deep/ .el-tabs__item:after {
    content: "";
    position: absolute;
    left: -1px;
    top: 8px;
    height: 26px;
    width: 1px;
    background-color: #dcdfe6;
  }
}
</style>
